package com.cango.student.tree;

import java.util.LinkedList;

public class TestBinaryTree {
    public static void main(String[] args) {
        TreeNode eight = new TreeNode(8, null, null);
        TreeNode five = new TreeNode(5, null, null);
        TreeNode six = new TreeNode(6, null, null);
        TreeNode seven = new TreeNode(7, null, null);
        TreeNode four = new TreeNode(4, eight, null);
        TreeNode two = new TreeNode(2, four, five);
        TreeNode three = new TreeNode(3, six, seven);
        TreeNode root = new TreeNode(1, two, three);

        // 先序遍历（递归）
        BinaryTree.PrintBinaryTreePreUnrecur(root);
        BinaryTree.PrintBinaryTreePreRecur(root);
        System.out.println();

        //中序遍历（递归）
        BinaryTree.PrintBinaryTreeMidUnrecur(root);
        BinaryTree.PrintBinaryTreeMidRecur(root);
        System.out.println();
        //后序遍历（递归）
        BinaryTree.PrintBinaryTreeBacUnrecur(root);
        BinaryTree.PrintBinaryTreeBacRecur(root);
        System.out.println();

        System.out.println();
        //层次遍历（非递归）
        BinaryTree.PrintBinaryTreeLayerUnrecur(root);
        System.out.println();

    }
}
